Ray tracing is a technique for presenting three-dimensional images on a two-dimensional display by tracing a path of light through pixels on an image plane. The technique is capable of producing extremely high-quality images. For example, the technique can include tracing one or more rays from each pixel in an image. By tracing a ray, a color value for the pixel can be computed. In some examples, different sets of rays can be traced to each pixel in the image such that color values for each pixel are accumulated to generate an image. However, as the number of pixels in an image increases, the computational cost also increases.
In addition, when a ray hits a surface in an image, it can generate new types of rays, e.g., reflection, refraction, and shadow rays. A reflection ray can be traced in the mirror-reflection direction. The closest object the reflection ray intersects can be what will be seen in the reflection. Refraction rays traveling through transparent material can work similarly, with the addition that a refractive ray could be entering or exiting the transparent material. A shadow ray can be traced toward one or more lights. If any opaque object is found between the surface and the light, the surface can be in shadow and the light may not illuminate the surface. However, as the number of additional rays increases, the computational costs for ray tracing increases even further.
In one illustrative example, an equation for a color value of a pixel can be: cp=∫px−1/2px+1/2∫py−1/2py+1/2∫t0t1∫−11∫−11∫01∫01ƒ(x, y, t, u, v, l1, l2)dl2 dl1 dv du dt dy dx. In the equation, cp can be a color of a pixel, the function ƒ(x, y, t, u, v, l1, l2) can represent a scene function that is used to identify the color of the pixel, the integrals for dl1 and dl2 can each represent a light source, the integrals du and dv can represent a lens position, the integral dt can represent a time, and the integrals dx and dy can represent a screen position. However, it should be recognized that the equation above is merely an example. An equation for a color value of a pixel could be different, with more or less variables and/or integrals.
To solve the equation recited above, it is obvious that an exact answer would be computationally expensive. Some solutions include using Monte Carlo samples to evaluate the integrals. However, too few Monte Carlo samples result in noise in a final image (e.g., inaccurate variation of brightness or color information). And the more Monte Carlo samples used, the more computation the final image requires. Therefore, there is a need to reduce the number of samples needed for ray tracing while still producing high-quality images.